/*
 * BSM6.0
 *
 * Copyright 2012-2013 (C) SINODATA CO., LTD. All Rights Reserved.
 */
package com.sinodata.bsm.inmp.service;

import java.util.HashMap;
import java.util.List;
import java.util.Set;

import org.apache.log4j.Logger;

import com.sinodata.bsm.inmp.conf.ConfManager;
import com.sinodata.bsm.inmp.finder.Finder;
import com.sinodata.bsm.inmp.opconf.OpConfManager;
import com.sinodata.bsm.inmp.opconf.OpDbServiceUtil;
import com.sinodata.bsm.inmp.util.WebServiceUtil;

/**
 * <p>
 * Description: 
 * </p>
 *
 * @author tangli
 * @version 1.0

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * 2012-5-22 上午9:38:53          tangli         1.0         To create
 * </p>
 *
 * @since 
 * @see     
 */
public class ResFindService {
    private static Logger logger = Logger.getLogger(ResFindService.class);

    /**
     * 
     */
    public ResFindService() {

    }

    /**
     * 资源发现的service
     * @param ip 要发现的资源IP
     * @param params 资源发现的参数配置
     * @param className 资源发现的类名
     * @return
     */
    public List<String[]> find(String ip, HashMap params, String className) {
        try {
            Finder finder = (Finder) Class.forName(className).newInstance();
            return finder.find(ip, params);
        } catch (Exception e) {
            logger.error("failed to find res,ip=" + ip + ",className=" + className);
            logger.error(e);
        }
        return null;
    }

    /**
     * ------------------------------以下为ZOHO集成------------------------------------------
     */

    /**
     * 获取网络设备列表
     * @return
     */
    public List<String[]> getNetDeviceList() {
        return OpDbServiceUtil.getInstance().getNetDeviceList();
    }

    /**
     * 获取OP网络设备的详细信息 res-->attr
     * @return
     */
    public List<String[]> getNetDeviceDetailList() {
        return OpDbServiceUtil.getInstance().getNetDeviceDetailList();
    }

    /**
     * 获取接口的详细信息  res-->attr --此数据无用
     * @return
     */
    //    public List<String[]> getNetIFDetailList() {
    //        return OpDbServiceUtil.getInstance().getNetIFDetailList();
    //    }

    /**
     * 获得指定网络设备的端口列表数据
     * @param kpiName
     * @return
     */
    public List<String[]> getIFDetailList(String inid) {
        return OpDbServiceUtil.getInstance().getIFDetailList(inid);
    }

    /**
     * 获取到资源类别树关系
     * @return
     */
    public List<String[]> getResTypeList() {
        return OpConfManager.getInstance().getResTypeList();
    }

    /**
     * -----------------------------以下为朗易集成-------------------------------------------------
     */

    /**
     * 从朗逸网管应用中获取网络资源列表
     * @param resType
     * @return
     */
    public List<String[]> getNetNodeList() {
        return WebServiceUtil.getInstance().getNetNodeList();
    }

    /**
     * 
     * @param jobId
     * @return
     */
    public List<String[]> getNodeInfoList(String key) {
        if (key == null || key.length() == 0) {
            return null;
        }
        String jobId = key.split("[,]")[0];

        WebServiceUtil.getInstance().getNodeInfo(jobId);

        return WebServiceUtil.getInstance().getNetMap().get(jobId).toAllList();

    }

    /**
     * 获取所有的关系数据
     * @return
     */
    public List<String[]> getRelationList() {
        return WebServiceUtil.getInstance().getRelationList("1");
    }

    /**
     * 获取所有的网络设备类别列表
     * @return
     */
    public Set<Long> getNetTypeSet() {
        return ConfManager.getInstance().getTypeSet();
    }

    /**
     * 
     * @return
     */
    public List<String[]> getOpNwList() {
        return null;
    }
}
